<?php

include_once('_path.php');

include_once(_CONST_LOCAL_INCLUDE_PATH."database.class.php");
$database = new Database($db_vars);

include_once(_CONST_LOCAL_INCLUDE_PATH."common.php");

session_name('foxid');

$quote = array();

$action = trim($_POST['action']);
$type = trim($_POST['type']);

$id = trim($_POST['id']);
  $quote['id'] = string_sql($id);
$rate = trim($_POST['rate']) + 1;
  $quote['rate'] = string_sql($rate);
$salt = trim($_POST['salt']);
$userid = trim($_POST['uid']);
  $quote['userid'] = string_sql($userid);

#检查
if(md5($userid + _CONST_COOKIE_SALT) != $salt){
  die;
}

echo "<script>";

if ($userid != "" && $action == 'update' && $type == 'series' && $id && $rate) {

	$quote['series_id'] = 0; if ($id > 0) $quote['series_id'] = string_sql($id);
	$quote['rating'] = 0; if ($rate > 0) $quote['rating'] = string_sql($rate);
	$quote['entry_time'] = string_sql(time());
	$quote['host'] = string_sql(fetch_alt_ip());

	$database->execute("INSERT INTO series_rating (user_id, series_id, rating, entry_time, host) VALUES (".$quote['userid'].", ".$quote['series_id'].", ".$quote['rating'].", ".$quote['entry_time'].", ".$quote['host'].") ON DUPLICATE KEY UPDATE entry_time = ".$quote['entry_time'].", rating = ".$quote['rating'].", host = ".$quote['host']);

	?>
	alert("Thanks we have received your vote.");
	<?
}

echo "</script>";

?>